#ifndef NOSAL_EXEC_INTERNAL_ERRNO_EXCEPTION_H_
#define NOSAL_EXEC_INTERNAL_ERRNO_EXCEPTION_H_

#include "exception.h"
#include <errno.h>
#include <string.h>

namespace netaos {
namespace nosal {
namespace exec {
namespace internal {

/// @brief Abstract base class for all exceptions related to calls that set the errno variable.
class ErrnoException : public Exception
{
    using Parent = Exception;

public:
    /// @brief Construct a new ErrnoExcpetion and record the error message for the given errno.
    ///
    /// @param errorNumber The C errno that has occured.
    explicit ErrnoException(std::int32_t const errorNumber) noexcept
        : Parent(::strerror(errorNumber))
    { }
};

}  // namespace internal
}  // namespace exec
}  // namespace nosal
}  // namespace netaos

#endif  // NOSAL_EXEC_INTERNAL_ERRNO_EXCEPTION_H_
